﻿Public Class ctrTraCuuTD

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        frmMain.TabControl1.TabPages.Remove(frmMain.TabControl1.SelectedTab)
    End Sub

    Private Sub rdMonAn_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdMonAn.CheckedChanged
        Dim bus As GeneralBUS = New GeneralBUS()
        gvThucDon.DataSource = bus.GetTable("select * from THUCDON where ThucUong=False")
    End Sub

    Private Sub rdThucUong_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdThucUong.CheckedChanged
        Dim bus As GeneralBUS = New GeneralBUS()
        gvThucDon.DataSource = bus.GetTable("select * from THUCDON where ThucUong=True")
    End Sub

    Private Sub rdTatCa_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdTatCa.CheckedChanged
        gvThucDon_Load()
    End Sub

    Private Sub btnTimKiem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimKiem.Click
        Dim bus As GeneralBUS = New GeneralBUS()
        Dim str As String = "select * from THUCDON where TenMon like '%" + txtTimKiem.Text + "%'"
        gvThucDon.DataSource = bus.GetTable(str)
    End Sub

    Private Sub ctrTraCuuTD_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        gvThucDon_Load()
        cmbLoaiMon_Load()
        rdTatCa.Checked = True
        txtTimKiem.Select()
    End Sub

    Private Sub gvThucDon_Load()
        Dim bus As ThucDonBUS = New ThucDonBUS()
        gvThucDon.DataSource = bus.GetTable()
    End Sub

    Private Sub cmbLoaiMon_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbLoaiMon.SelectionChangeCommitted
        Dim bus As GeneralBUS = New GeneralBUS()
        Dim str As String = "select * from THUCDON where MaLoai=" + cmbLoaiMon.SelectedValue.ToString()
        gvThucDon.DataSource = bus.GetTable(str)

        rdTatCa.Checked = False
        rdMonAn.Checked = False
        rdThucUong.Checked = False
    End Sub

    Private Sub cmbLoaiMon_Load()
        Dim bus As LoaiMonBUS = New LoaiMonBUS()
        cmbLoaiMon.DataSource = bus.GetTable()
        cmbLoaiMon.DisplayMember = "TenLoai"
        cmbLoaiMon.ValueMember = "MaLoai"
    End Sub
End Class
